import axios from "axios"
import { API } from '../../config'
import {takeEvery, put } from 'redux-saga/effects'
import { filter_products, filter_products_success } from "../actions/filter"


function* hanlefilterProducts(action){
  let res = yield axios.post(`${API}/products/filter`, action.payload)
  // console.log(res)
  yield put(filter_products_success({
    skip: action.payload.skip, ...res.data
  })
  )
}
export default function* filterSaga(){
  yield takeEvery(filter_products, hanlefilterProducts)
}
